using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;

namespace WindowsPhoneEssentials.Abstractions
{
    public class PhoneApplicationFrameWrapper : IPhoneApplicationFrame
    {
        private readonly PhoneApplicationFrame phoneApplicationFrame;

        public PhoneApplicationFrameWrapper(PhoneApplicationFrame phoneApplicationFrame)
        {
            this.phoneApplicationFrame = phoneApplicationFrame;
        }

        public Uri Source
        {
            get { return phoneApplicationFrame.Source; }
            set { phoneApplicationFrame.Source = value; }
        }

        public JournalOwnership JournalOwnership
        {
            get { return phoneApplicationFrame.JournalOwnership; }
            set { phoneApplicationFrame.JournalOwnership = value; }
        }

        public bool CanGoBack
        {
            get { return phoneApplicationFrame.CanGoBack; }
        }

        public bool CanGoForward
        {
            get { return phoneApplicationFrame.CanGoForward; }
        }

        public Uri CurrentSource
        {
            get { return phoneApplicationFrame.CurrentSource; }
        }

        public void StopLoading()
        {
            phoneApplicationFrame.StopLoading();
        }

        public void GoBack()
        {
            phoneApplicationFrame.GoBack();
        }

        public void GoForward()
        {
            phoneApplicationFrame.GoForward();
        }

        public PageOrientation Orientation
        {
            get { return phoneApplicationFrame.Orientation; }
        }

        public bool Navigate(Uri source)
        {
            return phoneApplicationFrame.Navigate(source);
        }

        public UriMapperBase UriMapper
        {
            get { return phoneApplicationFrame.UriMapper; }
            set { phoneApplicationFrame.UriMapper = value; }
        }

        public event NavigatedEventHandler Navigated
        {
            add { phoneApplicationFrame.Navigated += value; }
            remove { phoneApplicationFrame.Navigated -= value; }
        }

        public event NavigatingCancelEventHandler Navigating
        {
            add { phoneApplicationFrame.Navigating += value; }
            remove { phoneApplicationFrame.Navigating -= value; }
        }

        public event NavigationFailedEventHandler NavigationFailed
        {
            add { phoneApplicationFrame.NavigationFailed += value; }
            remove { phoneApplicationFrame.NavigationFailed -= value; }
        }

        public event NavigationStoppedEventHandler NavigationStopped
        {
            add { phoneApplicationFrame.NavigationStopped += value; }
            remove { phoneApplicationFrame.NavigationStopped -= value; }
        }

        public event FragmentNavigationEventHandler FragmentNavigation
        {
            add { phoneApplicationFrame.FragmentNavigation += value; }
            remove { phoneApplicationFrame.FragmentNavigation -= value; }
        }

        public event EventHandler<OrientationChangedEventArgs> OrientationChanged
        {
            add { phoneApplicationFrame.OrientationChanged += value; }
            remove { phoneApplicationFrame.OrientationChanged -= value; }
        }

        public event EventHandler<ObscuredEventArgs> Obscured
        {
            add { phoneApplicationFrame.Obscured += value; }
            remove { phoneApplicationFrame.Obscured -= value; }
        }

        public event EventHandler Unobscured
        {
            add { phoneApplicationFrame.Unobscured += value; }
            remove { phoneApplicationFrame.Unobscured -= value; }
        }

        public UIElement GetElement()
        {
            return phoneApplicationFrame;
        }

 #if WINDOWS_PHONE71
        public IEnumerable<JournalEntry> BackStack
        {
            get { return phoneApplicationFrame.BackStack; }
        }

        public JournalEntry RemoveBackEntry()
        {
            return phoneApplicationFrame.RemoveBackEntry();
        }

        public event EventHandler<JournalEntryRemovedEventArgs> JournalEntryRemoved
        {
            add
            {
                phoneApplicationFrame.JournalEntryRemoved += value;
            }
            remove
            {
                phoneApplicationFrame.JournalEntryRemoved -= value;
            }
        }
#endif
    }
}
